﻿using System;
using UnityEngine;

// Token: 0x02000222 RID: 546
public class BloodBounds : MonoBehaviour
{
	// Token: 0x06000B65 RID: 2917 RVA: 0x0005F8FC File Offset: 0x0005DAFC
	public static bool IsOddlyPlaced(Transform blood, Collider gts)
	{
		Vector3 extents = blood.GetComponent<MeshFilter>().mesh.bounds.extents;
		Vector3 b = blood.TransformVector(extents.x * Vector3.right);
		Vector3 b2 = blood.TransformVector(extents.z * Vector3.forward);
		Vector3 b3 = blood.TransformVector(Mathf.Max(extents.x, extents.z) * 0.5f * Vector3.down);
		float maxDistance = 2f * b3.magnitude;
		Vector3 a = blood.position - b3;
		Vector3 normalized = b3.normalized;
		RaycastHit raycastHit;
		return !gts.Raycast(new Ray(a + b, normalized), out raycastHit, maxDistance) || !gts.Raycast(new Ray(a - b, normalized), out raycastHit, maxDistance) || !gts.Raycast(new Ray(a + b2, normalized), out raycastHit, maxDistance) || !gts.Raycast(new Ray(a - b2, normalized), out raycastHit, maxDistance);
	}

	// Token: 0x06000B66 RID: 2918 RVA: 0x0005FA1D File Offset: 0x0005DC1D
	private void OnDestroy()
	{
		UnityEngine.Object.Destroy(this.t1);
		UnityEngine.Object.Destroy(this.t2);
		UnityEngine.Object.Destroy(this.t3);
		UnityEngine.Object.Destroy(this.t4);
	}

	// Token: 0x06000B67 RID: 2919 RVA: 0x0005FA4C File Offset: 0x0005DC4C
	public void setGTSBlood()
	{
		this.bloodMesh.localPosition = new Vector3(0f, this.bloodDepthAdjustment, 0f);
		this.t1.SetActive(true);
		this.t2.SetActive(true);
		this.t3.SetActive(true);
		this.t4.SetActive(true);
		this.t1.transform.parent = null;
		this.t2.transform.parent = null;
		this.t3.transform.parent = null;
		this.t4.transform.parent = null;
	}

	// Token: 0x06000B68 RID: 2920 RVA: 0x0005FAF0 File Offset: 0x0005DCF0
	private void FixedUpdate()
	{
		this.childCheck++;
		if (this.childCheck > this.childCheckTreshold && (this.t1 != null || this.t2 != null || this.t3 != null || this.t4 != null))
		{
			UnityEngine.Object.Destroy(base.gameObject);
		}
	}

	// Token: 0x06000B69 RID: 2921 RVA: 0x0005FB6B File Offset: 0x0005DD6B
	private void Start()
	{
		if (GlobalPreferences.CrushStickDuration.value == 0f)
		{
			base.enabled = false;
		}
	}

	// Token: 0x04001075 RID: 4213
	private const float bloodDepthScale = 0.5f;

	// Token: 0x04001076 RID: 4214
	public Transform bloodMesh;

	// Token: 0x04001077 RID: 4215
	public float bloodDepthAdjustment;

	// Token: 0x04001078 RID: 4216
	public float rayLength;

	// Token: 0x04001079 RID: 4217
	private bool outsideBounds;

	// Token: 0x0400107A RID: 4218
	private int childCheck;

	// Token: 0x0400107B RID: 4219
	public int childCheckTreshold = 5;

	// Token: 0x0400107C RID: 4220
	public GameObject t1;

	// Token: 0x0400107D RID: 4221
	public GameObject t2;

	// Token: 0x0400107E RID: 4222
	public GameObject t3;

	// Token: 0x0400107F RID: 4223
	public GameObject t4;
}
